package b_Money;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

public class MoneyTest {
    Currency SEK, DKK, NOK, EUR;
    Money SEK100, EUR10, SEK200, EUR20, SEK0, EUR0, SEKn100;
   
    @Before
    public void setUp() throws Exception {
        SEK = new Currency("SEK", 0.15);
        DKK = new Currency("DKK", 0.20);
        EUR = new Currency("EUR", 1.5);
        SEK100 = new Money(10000, SEK);
        EUR10 = new Money(1000, EUR);
        SEK200 = new Money(20000, SEK);
        EUR20 = new Money(2000, EUR);
        SEK0 = new Money(0, SEK);
        EUR0 = new Money(0, EUR);
        SEKn100 = new Money(-10000, SEK);
    }

    @Test
    public void testGetAmount() {
        assertNotNull(SEK100);
       
    }

    @Test
    public void testGetCurrency() {
    	assertSame(EUR10.getCurrency(),EUR20.getCurrency());
    }

    @Test
    public void testToString() {
    	
    		assertEquals("0.0 EUR", EUR0.toString());
      
    }

    @Test
    public void testGlobalValue() {
        
    }

    @Test
    public void testEqualsMoney() {
    	assertFalse(EUR10.equals(EUR20));
        
    }

    @Test
    public void testAdd() {
    	Money EUR30 = EUR20.add(EUR10);
    	assertTrue(EUR30.getAmount()== 3000);
        
    }

    @Test
    public void testSub() {
    	Money EUR30 = EUR20.sub(EUR10);
    	assertTrue(EUR30.getAmount()== 1000);
    }

    @Test
    public void testIsZero() {
    	assertEquals(EUR20.isZero(), false);
    }

    @Test
    public void testNegate() {
    	Money EUR30 = EUR20.negate();
    	double d =-( EUR20.getAmount());
    	assertTrue(d == EUR30.getAmount());
    	//////////////////////
    }

    @Test
    public void testCompareTo() {
    	assertTrue(EUR20.compareTo(EUR0)==1);
    }
}
